package com.miroservice.chapter2.web;


import com.miroservice.chapter2.pojo.Singer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import java.util.Set;

@Component
public class ValidateComponent {
    /**
     * 注入一个javax.validation.Validator 实例
     */
    @Autowired
    private Validator validator;


    public Set<ConstraintViolation<Singer>> validatorSinger(Singer singer) {
        return validator.validate(singer);
    }
}
